package com.caifu.excel.shopExcel;

import com.alibaba.excel.write.handler.SheetWriteHandler;
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
import com.alibaba.excel.write.metadata.holder.WriteWorkbookHolder;
import com.caifu.enums.LabelTypeEnum;
import com.caifu.excel.CommonHandle;
import com.caifu.service.ReportRecordService;

import java.util.HashMap;
import java.util.Map;

/**
 * ClassName : ShopSpinnerWriteHandler
 *
 * @author :  yb
 * @description ： 下拉框
 * @date : 2021-03-01 16:49
 */
public class ShopSpinnerWriteHandler implements SheetWriteHandler {


    private final ReportRecordService reportRecordService;

    public ShopSpinnerWriteHandler(ReportRecordService reportRecordService) {
        this.reportRecordService = reportRecordService;
    }

    @Override
    public void beforeSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) {

    }

    @Override
    public void afterSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) {


        //经营业态
        String[] businessTypeArr = reportRecordService.getLabelNameArray(LabelTypeEnum.JYYT.getKey());
        //经营状态
        String[] managementStatusArr = reportRecordService.getLabelNameArray(LabelTypeEnum.JYZT.getKey());
        //商铺产权 1-个人 2-企业
        String[] shopPropertyArr = new String[]{"个人", "企业"};

        Map<Integer, String[]> mapDropDown = new HashMap<>(15);
        mapDropDown.put(3, businessTypeArr);
        mapDropDown.put(4, managementStatusArr);
        mapDropDown.put(11, shopPropertyArr);

        CommonHandle commonHandle = new CommonHandle();
        commonHandle.processSpinnerWriter(writeSheetHolder, mapDropDown);

    }
}
